<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
		integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
	<title></title>
</head>

<body>
	<div class="modal fade" id="modal1">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
						Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.

						Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
						
						Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
						
						Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
						
						Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
						
						Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
						
						Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
						
						Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
						
						Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
						
						Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
						
						Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
						
						Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
						
						Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
						
						Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
						
						Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
						
						Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
						
						Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
						
						Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 垂直居中的模态框 -->
	<div class="modal fade" id="modal2">
		<div class="modal-dialog modal-dialog-centered">	<!-- modal-dialog-centered这个class要加在这里 -->
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
						垂直居中的模态框
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 使用栅格系统 -->
	<div class="modal fade" id="modal3">
		<div class="modal-dialog modal-dialog-centered">	<!-- modal-dialog-centered这个class要加在这里 -->
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
					<div class="container-fluid">
						<div class="row">
							<div class="col-md-4 bg-info border">第1列</div>
							<div class="col-md-4 bg-info border">第2列</div>
							<div class="col-md-4 bg-info border">第3列</div>
							<div class="col-md-12 bg-info border">第4列</div>
						</div>
						<div class="row">
							<div class="col bg-info border">第1列</div>
							<div class="col bg-info border">第2列</div>
							<div class="col bg-info border">第3列</div>
							<div class="col bg-info border">第4列</div>
						</div>
						<div class="row">
							<div class="col-md-5 bg-info">第1列</div>
							<div class="col-md-4 bg-info ml-auto">第2列</div>
						</div>
						<div class="row mt-3">
							<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12  bg-info border">超大屏6个，大屏4个，中等屏3个，小屏2个，超小屏1个</div>
							<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12  bg-info border">超大屏6个，大屏4个，中等屏3个，小屏2个，超小屏1个</div>
							<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12  bg-info border">超大屏6个，大屏4个，中等屏3个，小屏2个，超小屏1个</div>
							<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12  bg-info border">超大屏6个，大屏4个，中等屏3个，小屏2个，超小屏1个</div>
							<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12  bg-info border">超大屏6个，大屏4个，中等屏3个，小屏2个，超小屏1个</div>
							<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-12  bg-info border">超大屏6个，大屏4个，中等屏3个，小屏2个，超小屏1个</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 模态框相同内容不同 -->
	<div class="modal fade" id="modal4">
		<div class="modal-dialog modal-dialog-centered">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
					<form action="#">
						<div class="form-group">
							<label for="username" class="col-form-label">用户名：</label>
							<input type="text" class="form-control" id="username">
						</div>
						<div class="form-group">
							<label for="comment" class="col-form-label">评论：</label>
							<textarea class="form-control" id="comment"></textarea>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 尺寸大小-超大尺寸 -->
	<div class="modal fade bd-example-modal-xl" id="modal5">	<!-- 这里添加.bd-example-modal-xl -->
		<div class="modal-dialog modal-xl">	<!-- 这里添加.modal-xl -->
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
					超大尺寸模态框
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>
	<!-- 尺寸大小-大尺寸 -->
	<div class="modal fade bd-example-modal-lg" id="modal6">	<!-- 这里添加.bd-example-modal-lg -->
		<div class="modal-dialog modal-lg">	<!-- 这里添加.modal-lg -->
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
					大尺寸模态框
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>
	<!-- 尺寸大小-小尺寸 -->
	<div class="modal fade bd-example-modal-sm" id="modal7">	<!-- 这里添加.bd-example-modal-sm -->
		<div class="modal-dialog modal-sm">	<!-- 这里添加.modal-sm -->
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
					小尺寸模态框
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>

	<!-- data属性 -->
	<div class="modal fade" id="modal8">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
					data属性
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 方法与事件 -->
	<div class="modal fade" id="myModal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">标题</h5>
					<button class="close" data-dismiss="modal">
						<span>&times;</span>
					</button>
				</div>
				<div class="modal-body">
					data属性
				</div>
				<div class="modal-footer">
					<button class="btn btn-secondary" data-dismiss="modal">关闭</button>
					<button class="btn btn-primary">保存</button>
				</div>
			</div>
		</div>
	</div>




	<div class="container">
		<div class="row mt-5">
			<div class="col">
				<button class="btn btn-primary" data-toggle="modal" data-target="#modal1">普通模态框</button>
				<button class="btn btn-secondary" data-toggle="modal" data-target="#modal2">垂直居中的模态框</button>
				<button class="btn btn-danger" data-toggle="modal" data-target="#modal3">包含栅格系统的模态框</button>

				<button class="btn btn-success" data-toggle="modal" data-target="#modal4" data-whatever="kaivon">模态框相同内容不同</button>
				<button class="btn btn-success" data-toggle="modal" data-target="#modal4" data-whatever="陈学辉">模态框相同内容不同</button>
				<button class="btn btn-success" data-toggle="modal" data-target="#modal4" data-whatever="吃瓜群众">模态框相同内容不同</button>


				<button class="btn btn-info" data-toggle="modal" data-target="#modal5">超大尺寸模态框</button>
				<button class="btn btn-info" data-toggle="modal" data-target="#modal6">大尺寸模态框</button>
				<button class="btn btn-info" data-toggle="modal" data-target="#modal7">小尺寸模态框</button>

				<!-- data属性，需要添加在button身上 -->
				<!-- 
					data-backdrop	是否显示遮罩层
					data-keyboard	按esc是否关闭模态框
					data-focus		让模态框获取到焦点
					data-show		初始化时模态框是否显示
				 -->
				<button class="btn btn-dark" data-toggle="modal" data-target="#modal8" data-backdrop="true" data-keyboard="false" data-focus="true" data-show="false">data属性</button>

				<button class="btn btn-warning" id="myBtn">方法与事件</button>
			</div>
		</div>
	</div>

	<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
		integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
		crossorigin="anonymous"></script>
	<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
		integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
		crossorigin="anonymous"></script>

	<script>
		$('#modal4').on('show.bs.modal',function(ev){
			/*
				1、$(ev.relatedTarget)	这什值为点击的那个button
				2、.data('whatever')	这个是获取data-开关的属性的值
			 */

			var value=$(ev.relatedTarget).data('whatever');

			$(this).find('.modal-title').text('新评论来自于：'+value);
			$(this).find('.modal-body input').val(value);
		});

		//方法
		$('#myBtn').click(function(){
			$('#myModal').modal('show');
		});

		
		/* $('#myModal').modal('show');
		setTimeout(function(){
			$('#myModal').modal('hide');
		},2000); */

		//事件
		$('#myModal').on('show.bs.modal', function (e) {
			console.log('显示前');
		});
		$('#myModal').on('shown.bs.modal', function (e) {
			console.log('完全显示了');
		});
		$('#myModal').on('hide.bs.modal', function (e) {
			console.log('隐藏前');
		});
		$('#myModal').on('hidden.bs.modal', function (e) {
			console.log('完全隐藏了');
		});
	</script>
</body>
</html>
